﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Micrhard.FMCG.Server.Validator;
using Microhard.Core.DBUtility;
using Microhard.Notifications.Attrs;
using Micrhard.FMCG.Server.Notification;
using Microhard.Notifications.Enum;

namespace Micrhard.FMCG.Server.Models
{
    [AttrOfNotiMsgTemplate(Template = typeof(NoticeTemplate), MsgType = MsgType.Mail, GetSpecificUserClass = typeof(NoticeRec))]
    [FluentValidation.Attributes.Validator(typeof(NoticeModelValidator))]
    public class NoticeModel : BasePermissionModel
    {
        [ModelPKID]
        public Guid NoticeID { set; get; }
        public string Title { set; get; }
        public string Message { set; get; }
        public DateTime CreateTime { set; get; }
        public Guid CompanyID { set; get; }
        public Guid PubEmployeeID { set; get; }
        public int Type { set; get; }
        public List<EmployeeModel> RecEmployees { set; get; }

        public string RecEmployeeNames
        {
            get
            {
                StringBuilder sb = new StringBuilder();
                if (RecEmployees == null || RecEmployees.Count == 0)
                {
                    sb.Append("全员");
                }
                else
                {
                    RecEmployees.ForEach(e =>
                    {
                        sb.Append(e.Name);
                        sb.Append(",");
                    });
                }
                return sb.ToString();
            }
        }
    }

}
